/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cassandrawindow;

/**
 *
 * @author MT844
 */
public class IP2LocationUtils {
    public static final int UN_KNOWN = 0;
    public static final int HANOI = 4;
    public static final int HCM = 5;
    public static final int MIEN_BAC = 1;
    public static final int MIEN_TRUNG = 2;
    public static final int MIEN_NAM = 3;

    public static final int HAI_PHONG = 7;
    public static final int BAC_CAN = 8;
    public static final int BAC_GIANG = 9;
    public static final int BAC_NINH = 10;
    public static final int CAO_BANG = 11;
    public static final int DIEN_BIEN = 12;
    public static final int HA_GIANG = 13;
    public static final int HA_NAM = 14;
    public static final int HAI_DUONG = 15;
    public static final int HOA_BINH = 16;
    public static final int HUNG_YEN = 17;
    public static final int LAI_CHAU = 18;
    public static final int LANG_SON = 19;
    public static final int LAO_CAI = 20;
    public static final int NAM_DINH = 21;
    public static final int NINH_BINH = 22;
    public static final int PHU_THO = 23;
    public static final int QUANG_NINH = 24;
    public static final int SON_LA = 25;
    public static final int THAI_BINH = 26;
    public static final int THAI_NGUYEN = 27;
    public static final int TUYEN_QUANG = 28;
    public static final int VINH_PHUC = 29;
    public static final int YEN_BAI = 30;

    public static final int DA_NANG = 31;
    public static final int BINH_DINH = 32;
    public static final int BINH_PHUOC = 33;
    public static final int BINH_THUAN = 34;
    public static final int DAK_LAK = 35;
    public static final int DAK_NONG = 36;
    public static final int GIA_LAI = 37;
    public static final int HA_TINH = 38;
    public static final int KHANH_HOA = 39;
    public static final int KONTUM = 40;
    public static final int LAM_DONG = 41;
    public static final int NGHE_AN = 42;
    public static final int NINH_THUAN = 43;
    public static final int PHU_YEN = 44;
    public static final int QUANG_BINH = 45;
    public static final int QUANG_NAM = 46;
    public static final int QUANG_NGAI = 47;
    public static final int QUANG_TRI = 48;
    public static final int THANH_HOA = 49;
    public static final int THUA_THIEN_HUE = 50;
    public static final int TP_VINH = 51;

    public static final int BINH_DUONG = 52;
    public static final int CAN_THO = 53;
    public static final int AN_GIANG = 54;
    public static final int BARIA_VUNGTAU = 55;
    public static final int BAC_LIEU = 56;
    public static final int BEN_TRE = 57;
    public static final int CA_MAU = 58;
    public static final int DONG_NAI = 59;
    public static final int DONG_THAP = 60;
    public static final int HAU_GIANG = 61;
    public static final int KIEN_GIANG = 62;
    public static final int LONG_AN = 63;
    public static final int SOC_TRANG = 64;
    public static final int TAY_NINH = 65;
    public static final int TIEN_GIANG = 66;
    public static final int TRA_VINH = 67;
    public static final int VINH_LONG = 68;

    public static final String[] localSTR;

    static {
        localSTR = new String[69];
        localSTR[UN_KNOWN] = "Chua xac dinh";
        localSTR[MIEN_BAC] = "MIEN_BAC";
        localSTR[MIEN_NAM] = "MIEN_NAM";
        localSTR[MIEN_TRUNG] = "MIEN_TRUNG";

        localSTR[HANOI] = "Ha-Noi";
        localSTR[HAI_PHONG] = "Hai-Phong";
        localSTR[BAC_CAN] = "Bac-Can";
        localSTR[BAC_GIANG] = "Bac-Giang";
        localSTR[BAC_NINH] = "Bac-Ninh";
        localSTR[CAO_BANG] = "Cao-Bang";
        localSTR[DIEN_BIEN] = "Dien-Bien";
        localSTR[HA_GIANG] = "Ha-Giang";
        localSTR[HA_NAM] = "Ha-Nam";
        localSTR[HAI_DUONG] = "Hai-Duong";
        localSTR[HOA_BINH] = "Hoa-Binh";
        localSTR[HUNG_YEN] = "Hung-Yen";
        localSTR[LAI_CHAU] = "Lai-Chau";
        localSTR[LANG_SON] = "Lang-Son";
        localSTR[LAO_CAI] = "Lao-Cai";
        localSTR[NAM_DINH] = "Nam-Dinh";
        localSTR[NINH_BINH] = "Ninh-Binh";
        localSTR[PHU_THO] = "Phu-Tho";
        localSTR[QUANG_NINH] = "Quang-Ninh";
        localSTR[SON_LA] = "Son-La";
        localSTR[THAI_BINH] = "Thai-Binh";
        localSTR[THAI_NGUYEN] = "Thai-Nguyen";
        localSTR[TUYEN_QUANG] = "Tuyen-Quang";
        localSTR[VINH_PHUC] = "Vinh-Phuc";
        localSTR[YEN_BAI] = "Yen-Bai";

        localSTR[DA_NANG] = "Da-Nang";
        localSTR[BINH_DINH] = "Binh-Dinh";
        localSTR[BINH_PHUOC] = "Binh-Phuoc";
        localSTR[BINH_THUAN] = "Binh-Thuan";
        localSTR[DAK_LAK] = "Dak-Lak";
        localSTR[DAK_NONG] = "Dak-Nong";
        localSTR[GIA_LAI] = "Gia-Lai";
        localSTR[HA_TINH] = "Ha-Tinh";
        localSTR[KHANH_HOA] = "Khanh-Hoa";
        localSTR[KONTUM] = "Kontum";
        localSTR[LAM_DONG] = "Lam-Dong";
        localSTR[NGHE_AN] = "Nghe-An";
        localSTR[NINH_THUAN] = "Ninh-Thuan";
        localSTR[PHU_YEN] = "Phu-Yen";
        localSTR[QUANG_BINH] = "Quang-Binh";
        localSTR[QUANG_NAM] = "Quang-Nam";
        localSTR[QUANG_NGAI] = "Quang-Ngai";
        localSTR[QUANG_TRI] = "Quang-Tri";
        localSTR[THANH_HOA] = "Thanh-Hoa";
        localSTR[THUA_THIEN_HUE] = "Thua-Thien-Hue";
        localSTR[TP_VINH] = "TP-Vinh";

        localSTR[BINH_DUONG] = "Binh-Duong";
        localSTR[CAN_THO] = "Can-Tho";
        localSTR[HCM] = "TP-HCM";
        localSTR[AN_GIANG] = "An-Giang";
        localSTR[BARIA_VUNGTAU] = "Ba-Ria-Vung-Tau";
        localSTR[BAC_LIEU] = "Bac-Lieu";
        localSTR[BEN_TRE] = "Ben-Tre";
        localSTR[CA_MAU] = "Ca-Mau";
        localSTR[DONG_NAI] = "Dong-Nai";
        localSTR[DONG_THAP] = "Dong-Thap";
        localSTR[HAU_GIANG] = "Hau-Giang";
        localSTR[KIEN_GIANG] = "Kien-Giang";
        localSTR[LONG_AN] = "Long-An";
        localSTR[SOC_TRANG] = "Soc-Trang";
        localSTR[TAY_NINH] = "Tay-Ninh";
        localSTR[TIEN_GIANG] = "Tien-Giang";
        localSTR[TRA_VINH] = "Tra-Vinh";
        localSTR[VINH_LONG] = "Vinh-Long";
    }

    /**
     * Tính toán vùng miền của cityID
     *
     * @param cityID - ID tỉnh thành
     * @return - vùng miền tương ứng
     */
    public static int getLocalID(int cityID) {
        if (cityID == HANOI || (cityID >= HAI_PHONG && cityID <= YEN_BAI)) {
            return MIEN_BAC;
        } else if (cityID >= DA_NANG && cityID <= TP_VINH) {
            return MIEN_TRUNG;
        } else if (cityID == HCM
                || (cityID >= BINH_DUONG && cityID <= VINH_LONG)) {
            return MIEN_NAM;
        }
        return UN_KNOWN;
    }
}
